package com.yld.ch09;


public class Singleton {
	
	
	private static Singleton singleton=null;
	
	
	public static Singleton getInstance(){
		
		//第1次检查
		if(singleton == null){
			
			synchronized (Singleton.class) {
				//第2次检查
				if (singleton == null) {
					singleton = new Singleton();
				}
			}
		}
		
		return singleton;
	}
	
	
	private Singleton(){
		
		System.err.println("执行了一次构造方法....");
	}

}
